package com.view.apollo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.apollo.graphql.Query
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.network.okHttpClient
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient

class MainActivity : AppCompatActivity() {

    private val scope = MainScope()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val client = ApolloClient.Builder()
            .serverUrl("https://****.***.***/graphql")
            .okHttpClient(OkHttpClient())
            .build();

        scope.launch (Dispatchers.IO){
            val result = client.query(Query()).execute()
            result.data?.queryEvents?.forEach {

            }

        }

    }
}